feat(ProgramLogic): eRHL program logic, TV distance, Fiat-Shamir, and ElGamal IND-CPA#116
feat(ProgramLogic): eRHL program logic, TV distance, Fiat-Shamir, and ElGamal IND-CPA#116
Conversation
…ative relational logic, and ElGamal wiring Add the complete program logic overhaul skeleton: - Unary/SimulateQ: wp rules for simulateQ, liftComp, stateful oracle impls - Relational/Quantitative: eRHL (ℝ≥0∞-valued) with pRHL and apRHL as special cases - Relational/SimulateQ: relational simulateQ coupling and identical-until-bad lemma - Notation: GameEquiv, AdvBound, game_wp/game_rel tactic macros - Basic: query coupling rules (identity + bijection/rnd) - RelationalAlgebra: two-sided StateT instance - SampleableType: bijective map + uniform bool guessing lemmas - HoareTriple: wp_ite rule - ElGamal: helper lemma statements for allRandomHalf and DDH step All proofs are either completed or sorry'd for parallel proof-filling. Made-with: Cursor
…l/SimulateQ Fill in proofs for relational coupling rules and simulateQ theorems: - Basic.lean: relTriple_query, relTriple_query_bij (bijection/"rnd" rule), plus relTriple_refl, relTriple_post_mono, relTriple_bind, and evalDist/probOutput equivalence bridges - SimulateQ.lean: relTriple_simulateQ_run (stateful oracle coupling by induction on OracleComp), relTriple_simulateQ_run' (output-only projection), and helper relTriple_map Made-with: Cursor
Unary/SimulateQ: all sorry's resolved — wp_simulateQ_eq, wp_liftComp, wp_simulateQ_run'_eq now fully proven. Relational/SimulateQ: fix "identical until bad" theorem signature — add required monotonicity hypotheses (h_mono₁, h_mono₂) without which the theorem is false. All helper lemmas fully proven; one sorry remains in the final tvDist bound (ENNReal algebra). Made-with: Cursor
Resolve three sorry's in the IND-CPA game-hopping proof: - randomMaskedCipher_dist_indep: left-multiplication bijection argument - IND_CPA_hybridOracle_allRandom_eqDist: relational coupling via evalDist equality - IND_CPA_allRandomHalf: uniform bit guessing reduces to probOutput_decide_eq_uniformBool_half Also add helper lemmas (evalDist_simulateQ_run_eq_of_impl_evalDist_eq, hybridChallengeOracle_allRandom_evalDist_eq) used in the coupling proof. Made-with: Cursor
🤖 AI-Generated PR SummaryFiles Changed:
Overview of Changes: Here is a summary of the key changes:
New 'sorry's: 11 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b32f36d81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /-- `game_wp` decomposes unary WP goals by repeatedly applying WP rules. -/ | ||
| macro "game_wp" : tactic => | ||
| `(tactic| ( | ||
| simp only [game_rule] |
There was a problem hiding this comment.
Replace undefined
game_rule references in game tactics
game_wp/game_rel both call simp with game_rule, but there is no game_rule lemma anywhere in the repository (a repo-wide rg "\bgame_rule\b" only finds these macro lines). As a result, the macros elaborate but fail when invoked with an unknown-constant error, so the new user-facing game-hopping tactics are not actually usable.
Useful? React with 👍 / 👎.
…d program logic tactics Rename `SigmaAlg` → `SigmaProtocol` with security property definitions (completeness, special soundness, HVZK). Add `game_rule` simp attribute, extend `game_wp`/`game_rel`/`coupling`/`game_hop` tactics, and wire up Schnorr sigma protocol and Fiat-Shamir examples. Made-with: Cursor
…l equivalence Fill the three Part A sorry's in HHS_Elgamal.lean: - hybridChallengeOracle_allRandom_evalDist_eq: the challenge oracle produces equal distributions for b=true vs b=false when realUntil=0, via StateT/liftM unfolding and randomMaskedCipher_dist_indep. - evalDist_monadLift_self: identity lift simplification using simulateQ_id'. - Minor SubSpec.lean comment fix. Made-with: Cursor
…ij, tvDist_simulateQ bound Fill sorry's in three program logic files: - wp_uniformSample via μ_bind_eq_tsum decomposition - relTriple_uniformSample_bij via relWP coupling with bijection - tvDist_simulateQ_le_probEvent_bad via fundamental lemma of game playing Made-with: Cursor
… and OptimalCoupling - Generalize IsQueryBound to arbitrary budget types; recover classical per-index bound as IsPerIndexQueryBound - Prove Schnorr sigma protocol completeness, special soundness, and HVZK - Fill eRelTriple_pure, relTriple'_bind, and backward direction of relTriple'_iff_couplingPost - Add OptimalCoupling.lean with compactness infrastructure for coupling space - Inline trueProbReal, weaken IND_CPA hybrid theorem hypotheses - Remove unused DecidableEq constraints from DDH/HHS definitions Made-with: Cursor
🤖 Gemini PR SummaryProgram Logic & Mathematical Foundations
Cryptographic Applications
Infrastructure & Automation
Critical Technical Note: Sorry Inventory (6 net new)
Statistics
Lean Declarations ✏️ **Removed:** 4 declaration(s)
✏️ **Added:** 81 declaration(s)
✏️ **Affected:** 15 declaration(s) (line number changed)
✅ **Removed:** 2 `sorry`(s)
❌ **Added:** 6 `sorry`(s)
📄 **Per-File Summaries**
Last updated: 2026-03-07 02:34 UTC. |
…ain) Define IND_CPA_allRealChallengeOracle / IND_CPA_queryImpl_allReal and the lemma chain (allReal_eq_hybrid_on_bounded, hybrid_q_probOutput_eq_allReal, allReal_evalDist_proj_eq_real, hybrid_q_run'_evalDist_eq_real) that proves IND_CPA_HybridGame_q_eq_game: hybrid game at q equals the real IND-CPA game when the adversary MakesAtMostQueries q. Land ElGamal_IND_CPA_le_q_mul_ddh with the locked-in statement using MakesAtMostQueries. Remove unused ddh_decomp_two_games, inline trueProbReal, tighten longFile limit. Four sorry's remain in the allReal simulation lemmas (term-matching issues, not logical gaps). Made-with: Cursor
Match upstream mathlib PR #35826 review feedback: remove [DecidableEq β] from type signatures where it is only needed in the proof, and use `classical` instead. Made-with: Cursor
Complete the final allReal and projection lemmas so the HHS ElGamal IND-CPA proof closes without remaining sorries. Made-with: Cursor
Establish the finite-support projection and coupling reconstruction lemmas so the compactness argument yields an actual maximizing coupling. Made-with: Cursor
Prove the remaining Wave 1 eRHL bridge lemmas so the quantitative relational logic file builds cleanly except for the intended Wave 2 placeholders. Made-with: Cursor
…mpleteness Add total variation distance infrastructure (SPMF.tvDist, monadic tvDist), probability lemmas (probOutput_bind_uniformBool, monadLift_eq_self, evalDist_simulateQ_run_eq), and extend program logic with quantitative relational rules. Begin Fiat-Shamir completeness proof and fix ElGamal linter warnings. Made-with: Cursor
Summary
Adds a game-hopping program logic framework (relational Hoare logic, TV distance infrastructure, oracle simulation rules) and applies it to prove ElGamal IND-CPA security reduces to DDH.
Program Logic (
VCVio/ProgramLogic/)wp_simulateQ_eq,wp_liftComp,wp_simulateQ_run'_eq) for reasoning throughsimulateQboundaries.wp_ite,wp_uniformSamplerules.RelTriple) with coupling rules for oracle queries — identity coupling, bijection/rnd rule,relTriple_bind,relTriple_refl, and bridges toevalDist/probOutput.simulateQby induction onOracleComp, and the fundamental lemma of game playing (tvDist_simulateQ_le_probEvent_bad).GameEquiv,AdvBound, bridge lemmas fromRelTripleto game equivalence.TV Distance & Probability (
VCVio/EvalDist/TVDist.lean)SPMF.tvDist, monadictvDistwith triangle inequality, map/bind monotonicity.tvDist_le_probEvent_of_probOutput_eq_of_not— "identical until bad" TV bound.abs_probOutput_toReal_sub_le_tvDist— Bool advantage ≤ TV distance.Supporting Library
ToMathlib/): Existence of optimal couplings for PMFs.probOutput_bind_uniformBool(uniform-Boolean mixture),probOutput_map_bijective_uniformSample.monadLift_eq_selfsimp lemma.evalDist_simulateQ_run_eq_of_impl_evalDist_eq.game_rulesimp set.Fiat-Shamir (
VCVio/CryptoFoundations/FiatShamir.lean)perfectlyCorrect) — 1 sorry remaining (simp regression from new@[simp] monadLift_eq_self).ElGamal IND-CPA (
Examples/HHS_Elgamal.lean)ElGamal_IND_CPA_le_q_mul_ddh— IND-CPA advantage ≤ q × DDH advantage.Schnorr (
Examples/HHS_Schnorr.lean)Sorry inventory (6 net new)
Relational/Quantitative.leanFiatShamir.leanFork.leanTest plan
lake buildpasses (2764 jobs, zero errors)